package com.lun.easy;

import com.lun.util.BinaryTree.TreeNode;

public class SecondMinimumNodeInABinaryTree {
    public int findSecondMinimumValue(TreeNode root) {
        if(root == null || root.left == null)
        	return -1;
        
        int left  = (root.left.val  == root.val) ? // 
        		findSecondMinimumValue(root.left)  : root.left.val;
        
        int right = (root.right.val == root.val) ? //
        		findSecondMinimumValue(root.right) : root.right.val;

        if(left  == -1)
        	return right;
        if(right == -1)
        	return left;

        return Math.min(left, right);
    }
}
